<template>
  <div>
    <div class="slot">
      <div class="top">
        <div class="return" @click="goback">
          <img src="@/assets/my/zuo.png" alt />
        </div>
        <span>选择仓库</span>
      </div>
    </div>
    <div class="main">
      <div class="main_center">
        <div class="list" v-for="item in houselist" :key="item.id" @click="xuanze(item.id)">
          <div :class="id===item.id?'icon1':'icon'" ></div>
          <div class="list_info">
            <div class="info_title">{{item.name}}</div>
            <div class="info_main">{{item.province}}{{item.city}}{{item.area}}{{item.detail}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      houselist:[],
      type:0,
      orderid:0,
      id:0,
      token:""
    };
  },
  methods: {
    goback() {
      if (this.type == 2) {
        this.$router.push({
          path: "/confirmorder",
          query: { cangkid:this.id, order_id: this.orderid,type:this.type , cart_ids: this.cart_ids},
        });
      }
    },
    xuanze(id) {
      this.id = id
      this.goback()
    }
  },
  mounted() {
    this.token = window.localStorage.getItem("token")
    axios.post("/index/order/house", this.$qs.stringify({ token: this.token })).then((res) => {
      console.log(res.data);
      if (res.data.code === 1) {
        this.houselist = res.data.data;
      } else {
        this.$toast(res.data.msg);
      }
    });
    this.type = this.$route.query.type;
    this.orderid = this.$route.query.order_id;
    this.cart_ids = this.$route.query.cart_ids;
  },
};
</script>

<style lang="scss" scoped>
.slot {
  width: 100%;
  height: 44px;
  .top {
    width: 100%;
    height: 44px;
    display: flex;display: -webkit-flex;
    justify-content: center;
    align-items: center;
    background: white;
    position: fixed;
    top: 0;
    left: 0;
    .return {
      width: 38px;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      display: flex;display: -webkit-flex;
      justify-content: center;
      align-items: center;
      img {
        width: 8px;
        height: 15px;
      }
    }
    span {
      font-size: 18px;
      font-family: PingFang SC;
      font-weight: bold;
      color: #000000;
      line-height: 44px;
    }
  }
}
.main {
  width: 100%;
  border-top: 8px solid #f8f8f8;
  .main_center {
    width: 345px;
    margin: auto;
    .list {
      width: 100%;
      border-bottom: 1px solid #f8f8f8;
      display: flex;display: -webkit-flex;
      align-items: center;
      .icon {
        width: 17px;
        height: 17px;
        background: url("../../assets/pblic/noxuan.png") no-repeat center center;
      }
      .icon1 {
        width: 17px;
        height: 17px;
        background: url("../../assets/pblic/hgou2.png") no-repeat center center;
      }
      .list_info {
        margin-left: 12px;
        .info_title {
          font-size: 15px;
          font-family: PingFang SC;
          font-weight: 500;
          color: #000000;
          line-height: 15px;
          margin-top: 18px;
        }
        .info_main {
          font-size: 12px;
          font-family: PingFang SC;
          font-weight: 500;
          color: #444444;
          line-height: 15px;
          margin-top: 10px;
          margin-bottom: 15px;
        }
      }
    }
  }
}
</style>